package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbEnterpriseArchitecture;
import com.ruoyi.wb.dto.WbEnterpriseArchitectureDto;
import com.ruoyi.wb.service.IWbEnterpriseArchitectureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 企业认证架构Controller
 * 
 * @author ruoyi
 * @date 2024-10-24
 */
@RestController
@RequestMapping("/wb/architecture")
@Api(tags="企业架构管理")
public class WbEnterpriseArchitectureController extends BaseController
{
    @Autowired
    private IWbEnterpriseArchitectureService wbEnterpriseArchitectureService;





    /**
     * 查询企业认证架构列表
     */
    @ApiOperation("根据企业id获取认证架构")
    @GetMapping("/byAuthId")
    public AjaxResult byAuthId(WbEnterpriseArchitectureDto wbEnterpriseArchitectureDto)
    {
        return wbEnterpriseArchitectureService.selectWbEnterpriseArchitecturebyAuthId(wbEnterpriseArchitectureDto);
    }

    /**
     * 查询企业认证架构列表
     */
    @ApiOperation("查询企业认证架构列表")
    @GetMapping("/list")
    public TableDataInfo list(WbEnterpriseArchitecture wbEnterpriseArchitecture)
    {
        List<WbEnterpriseArchitecture> list = wbEnterpriseArchitectureService.selectWbEnterpriseArchitectureList(wbEnterpriseArchitecture);
        return getDataTable(list);

    }

    /**
     * 导出企业认证架构列表
     */
    @ApiOperation("导出企业认证架构列表")
    @Log(title = "企业认证架构", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbEnterpriseArchitecture wbEnterpriseArchitecture)
    {
        List<WbEnterpriseArchitecture> list = wbEnterpriseArchitectureService.selectWbEnterpriseArchitectureList(wbEnterpriseArchitecture);
        ExcelUtil<WbEnterpriseArchitecture> util = new ExcelUtil<WbEnterpriseArchitecture>(WbEnterpriseArchitecture.class);
        util.exportExcel(response, list, "企业认证架构数据");
    }

    /**
     * 获取企业认证架构详细信息
     */
    @ApiOperation("根据架构id获取详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wbEnterpriseArchitectureService.selectWbEnterpriseArchitectureById(id));
    }

    /**
     * 新增企业认证架构
     */
    @ApiOperation("新增企业认证架构")
    @Log(title = "企业认证架构", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbEnterpriseArchitecture wbEnterpriseArchitecture)
    {
        return toAjax(wbEnterpriseArchitectureService.insertWbEnterpriseArchitecture(wbEnterpriseArchitecture));
    }

    /**
     * 修改企业认证架构
     */
    @ApiOperation("修改企业认证架构")
    @Log(title = "企业认证架构", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbEnterpriseArchitecture wbEnterpriseArchitecture)
    {
        return toAjax(wbEnterpriseArchitectureService.updateWbEnterpriseArchitecture(wbEnterpriseArchitecture));
    }

    /**
     * 删除企业认证架构
     */
    @ApiOperation("删除企业认证架构")
    @Log(title = "企业认证架构", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbEnterpriseArchitectureService.deleteWbEnterpriseArchitectureByIds(ids));
    }
}
